import React from 'react';
import { Dropdown, Menu } from '@teamix/ui';
import { ButtonIcon } from '@alife/devops-ui';
import { navigate } from 'utils/router';
import intl from '../../../../../../../../locale';

export default class ExtraBtn extends React.Component {
  render() {
    const { plugin, serviceData } = this.props;
    // 没开启则禁用
    if (
      !(serviceData && plugin.key && serviceData[plugin.key] && serviceData[plugin.key].enabled)
    ) {
      return <ButtonIcon disabled name="more-line" />;
    }

    return (
      <React.Fragment>
        <Dropdown
          trigger={
            <ButtonIcon
              onClick={(e) => {
                e.preventDefault();
                e.stopPropagation();
              }}
              name="more-line"
            />
          }
          triggerType="hover"
          align="cl cr"
          // offset={[0, 8]}
          hasSelectedIcon={false}
        >
          <Menu>
            <Menu.Item
              key="new"
              onClick={() => {
                navigate(`/${window.FORCE.pathResource.fullPath}/settings/services`);
              }}
            >
              {intl.get({
                id: 'code-assets.containers.projectSecurityTab.extraBtn.ModifySettings',
                defaultMessage: '修改设置',
              })}
            </Menu.Item>
          </Menu>
        </Dropdown>
      </React.Fragment>
    );
  }
}
